package com.fangyi.yunmusic.controller.es;

import com.fangyi.yunmusic.pojo.Playlist;
import com.fangyi.yunmusic.pojo.es.*;
import com.fangyi.yunmusic.service.es.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class ComprehensiveSearchController {
    @Autowired
    private PlaylistSearchService playlistSearchService;
    @Autowired
    private AlbumSearchService albumSearchService;
    @Autowired
    private SongSearchService songSearchService;
    @Autowired
    private ArtistSearchService artistSearchService;

    @GetMapping("/comprehensive/search")
    public Object queryComprehensive(Integer pageNum, Integer pageSize, String query) {
        Page<PlaylistDocument> playlistPage = playlistSearchService.queryPlaylist(pageNum, pageSize, query);
        Page<AlbumDocument> albumPage = albumSearchService.queryAlbum(pageNum, pageSize, query);
        Page<SongDocument> songPage = songSearchService.querySong(pageNum, pageSize, query);
        Page<ArtistDocument> artistPage = artistSearchService.queryArtist(pageNum, pageSize, query);
        Map<String ,Page<?>> maps=new HashMap<>();
        maps.put("playlistPage",playlistPage);
        maps.put("albumPage",albumPage);
        maps.put("songPage",songPage);
        maps.put("artistPage",artistPage);

        return maps;
    }
}
